package com.docker.core.plugin;

import com.docker.core.third.docker.DockerTidyThread;
import com.docker.sys.app.AppService;
import com.docker.sys.dic.DicService;
import com.docker.sys.permission.PermissionService;
import com.jfinal.aop.Aop;
import com.jfinal.core.JFinal;
import com.jfinal.log.Log;
import com.jfinal.plugin.IPlugin;

public class SysInitPlugin implements IPlugin {

    private static final Log log = Log.getLog(SysInitPlugin.class);

    private PermissionService permissionService = Aop.get(PermissionService.class);
    private DicService dicService = Aop.get(DicService.class);
    private AppService appService = Aop.get(AppService.class);

    @Override
    public boolean start() {
        log.info("系统加载...");
        log.info("初始化系统权限：" + permissionService.addNew(JFinal.me().getAllActionKeys()));
        log.info("缓存字典信息：" + dicService.cache());
        log.info("缓存应用信息：" + appService.cache());
        log.info("自动整理docker连接池：" + DockerTidyThread.start());
        log.info("系统加载完成...");
        return true;
    }

    @Override
    public boolean stop() {
        log.info("停止调度任务...");
        return false;
    }

}
